//
//  TXPRadioDetailTableViewCell.m
//  StayAwhile
//
//  Created by dllo on 16/1/30.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "TXPRadioDetailTableViewCell.h"

@interface TXPRadioDetailTableViewCell ()
@property (nonatomic, retain) UIImageView *coverImg;
@property (nonatomic, retain) UILabel *titleLabel;
@property (nonatomic, retain) UILabel *countLabel;
@property (nonatomic, retain) UIImageView *tagImg;
@end
@implementation TXPRadioDetailTableViewCell

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    if ([super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self createSubView];
    }
    return self;
}
- (void)createSubView{
    self.coverImg = [[UIImageView alloc] init];
    self.coverImg.backgroundColor = [UIColor redColor];
    [self.contentView addSubview:self.coverImg];
    
    [self.coverImg mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.edges.equalTo(self.contentView).with.insets(UIEdgeInsetsMake(13, 30, 13, WIDTH - 100));
    }];
    
    self.titleLabel = [[UILabel alloc] init];
    self.titleLabel.backgroundColor = [UIColor clearColor];
    self.titleLabel.font = [UIFont systemFontOfSize:19];
    self.titleLabel.text = @"独家记忆";
    [self.contentView addSubview:self.titleLabel];
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(self.coverImg.mas_right).offset(10);
        make.right.mas_equalTo(self.mas_right).offset(-40);
        make.top.mas_equalTo(self.mas_top).offset(12);
        make.bottom.mas_equalTo(self.mas_top).offset(40);
    }];
    
    
    self.tagImg = [[UIImageView alloc] init];
    self.tagImg.image = [UIImage imageNamed:@"listen"];
    [self.contentView addSubview:self.tagImg];
    [self.tagImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.coverImg.mas_right).offset(10);
        make.right.mas_equalTo(self.mas_right).offset(-280);
        make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(20);
        make.bottom.mas_equalTo(self.mas_bottom).offset(-20);
        
    }];
    
    self.countLabel = [[UILabel alloc] init];
    self.countLabel.font = [UIFont systemFontOfSize:16];
    self.countLabel.text = @"12345678";
    self.countLabel.textColor = [UIColor colorWithRed:170 / 255.0 green:170 / 255.0 blue:170 / 255.0 alpha:1.0];
    [self.contentView addSubview:self.countLabel];
    [self.countLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.tagImg.mas_right).offset(10);
        make.right.mas_equalTo(self.mas_right).offset(-10);
        make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(20);
        make.bottom.mas_equalTo(self.mas_bottom).offset(-20);
        
    }];
    
}
- (void)setModel:(TXPRadioModel *)model{
    
    _model = model;
    
    [self.coverImg sd_setImageWithURL:[NSURL URLWithString:_model.coverimg] placeholderImage:[UIImage imageNamed:@"c3b08068f41ac81243561c5d387ea55c.jpg"]];
    self.titleLabel.text = _model.title;
    self.countLabel.text = _model.musicVisit;
}

@end
